import { useI18n } from 'vue-i18n'

import { UserCriteria } from '@/apis/user/type/dto'
import { SexEnum, StatusEnum } from '@/types/enum'
import { FormInputList } from '@/types/interface'

export function useSearchForm() {
  const { t } = useI18n()

  // 表单配置
  const searchFormList = computed((): FormInputList<UserCriteria> => {
    return [
      {
        key: 'username',
        type: 'input',
        label: t('common.username'),
        placeholder: t('common.please_enter', { name: t('common.username') }),
      },
      {
        key: 'sex',
        type: 'select',
        label: t('user.sex'),
        placeholder: t('common.please_select', { name: t('user.sex') }),
        options: [
          { label: t('common.sex_male'), value: SexEnum.MALE },
          { label: t('common.sex_female'), value: SexEnum.FEMALE },
        ],
      },
      {
        key: 'nick_name',
        type: 'input',
        label: t('user.nick_name'),
        placeholder: t('common.please_enter', { name: t('user.nick_name') }),
      },

      {
        key: 'phone',
        type: 'input',
        label: t('user.phone'),
        placeholder: t('common.please_enter', { name: t('user.phone') }),
      },
      {
        key: 'email',
        type: 'input',
        label: t('common.email'),
        placeholder: t('common.please_enter', { name: t('common.email') }),
      },
      {
        key: 'status',
        type: 'select',
        label: t('common.status'),
        placeholder: t('common.please_select', { name: t('common.status') }),
        options: [
          { label: t('common.status_enable'), value: StatusEnum.DYNAMIC },
          { label: t('common.status_disable'), value: StatusEnum.STATIC },
        ],
      },
      {
        key: 'create_time',
        type: 'date-picker',
        label: t('common.create_time'),
      },
    ]
  })

  return {
    searchFormList,
  }
}
